# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: mains.py
"""

from flask import Flask,render_template,jsonify,request
import crawl

app = Flask(__name__)

# API
@app.route('/',methods=['get'])  # API
def index():
    # 视图
    return render_template('index.html')


@app.route('/b',methods=['GET'])  # API
def index1():
    # 视图
    return render_template('base/base.html')


@app.route('/c')  # API
def index2():
    # 视图
    data = {
        'name':'貂蝉',
        'age':18
    }
    return jsonify(data=data)


@app.route('/api')
def get_datas():
    id = request.args.get('data')
    sign = request.args.get('sign')
    if sign != "202CB962AC59075B964B07152D234B70":
        data = {
            'message':'大哥 别爬了 你的参数不对！！！  再回去练一练'
        }
        return jsonify(data=data)
    data = crawl.get_data(id)
    return jsonify({'data':data})


if __name__ == '__main__':
    app.run()


